<?php
/**
 * 访问操作日志管理
 * @author huanran.zhao
 * @since 1.0 - 2011-11-12
 */
class VisitLogApp extends CommonApp {
	
	public function indexAct() {
		//search
		$where = '1 ';
		if(My::arr2var($_GET,'user_name')!='')
			$where .= "AND `user_name` like '%".I('get.user_name')."%' ";
		if(My::arr2var($_GET,'ip')!='')
			$where .= "AND `ip` like '%".I('get.ip')."%' ";
		$result['page'] = My::page(DB('visit_log')->where($where)->cache()->count());
		$result['data'] = DB('visit_log')->where($where)->cache()->order("`time` DESC")->limit($result['page']['limits'])->select();
		$this->assign('result',$result);
		//display
		$this->display();
	}
		

	/**
	 * 删除
	 */
	public function deleteAct(){	
		$ids = I('request.ids');
		$sql = "id IN(".$ids.")";
		
		if (DB('visit_log')->where($sql)->delete()){
			$this->ajaxReturn(200, L('delete.success').$msg);
		}else {
			$this->ajaxReturn(300, L('delete.failure'));
		}	
	}

}